package com.mhb.generator.config.query;

import com.mhb.generator.config.interfaces.DbQueryInterface;
import com.mhb.generator.util.StringUtil;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * Mysql 数据库
 *
 * @author 博博
 * @Title: MySqlQuery
 * @time 2019/12/18 0018 14:37
 */
public class MySqlQuery implements DbQueryInterface {
    @Override
    public String tablesSql() {
        return "show table status WHERE 1=1 ";
    }

    @Override
    public String tablesSql(String[] tables) {
        return String.format("show table status WHERE name in(%s)", Arrays.stream(tables).map(StringUtil::quotaMark).collect(Collectors.joining(",")));
    }

    @Override
    public String tableFieldsSql() {
        return "show full fields from `%s`";
    }

    @Override
    public String tableName() {
        return "NAME";
    }


    @Override
    public String tableComment() {
        return "COMMENT";
    }


    @Override
    public String fieldName() {
        return "FIELD";
    }


    @Override
    public String fieldType() {
        return "TYPE";
    }


    @Override
    public String fieldComment() {
        return "COMMENT";
    }


    @Override
    public String fieldKey() {
        return "KEY";
    }

    @Override
    public String fieldExtra() {
        return "EXTRA";
    }

    @Override
    public String fieldNull() {
        return "NULL";
    }


    @Override
    public String[] fieldCustom() {
        return new String[0];
    }
}
